<template>
  <div class="mobile-search">
    <div class="mobile-top"></div>
    <div class="mobile-bottom"></div>
    <!-- <el-header>
      <img src="../assets/navtop-b.png" alt="" width="100%" style="padding-top:20px;">
    </el-header>
    <div>
      <div style="padding-top:50%;">

          <el-input v-model="medcode" placeholder="请输入追溯码"></el-input>
          <div style="margin-top:50px;">    
             <el-button @click="codeSearch" medium  icon="">查询</el-button >
                    <el-button @click="goScan" medium>扫一扫</el-button >

          <input type="file" capture=camera accept="image/*" id="scanCode" style="display:none">
          </div>
     
</div>
    </div> -->
  </div>
</template>

<script>
  export default {
    data() {
      return {
        medcode: '',
        adminToken: "YWRtaW46Zm9kYWFpMTIz"
      };
    },
    methods: {

      codeSearch() {
        this.$http({
          url: '/trace-code/' + this.medcode + '/',
          methods: 'get',
          headers: {
            'Authorization': 'Basic ' + this.adminToken
          },
        }).then(response => {
          this.traceData = response.data
          console.log(response.data)
          this.$message({
            message: '查询成功',
            showClose: true,
            type: 'success'
          });
          this.$router.push({
            name: 'medcode-detail-m',
            params: {
              codeId: this.medcode,
              type: 'code'
            }
          })
        }).catch(error => {
          if (error.response) {
            // The request was made and the server responded with a status code
            // that falls out of the range of 2xx
            console.log(error.response.data);
            // console.log(error.response.status);
            // console.log(error.response.headers);
          } else if (error.request) {
            console.log(error.request);
          } else {
            console.log('Error', error.message);
          }
          // console.log(error.config);
          this.$message({
            message: '查询失败',
            showClose: true,
            type: 'error'
          });
        });
      },
      goScan(){
        $('#scanCode').click()
      },
      handleSelect(item) {
        console.log(item);
      }
    },
    mounted() {

    }
  }

</script>

<style scoped>
  .mobile-search {
    height: 100%;
    background:url('../assets/background-p1.png')!important
  }

</style>
